<template>
  <div @click="$emit('select', obj.dogName)">
    <img
      src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg"
      alt=""
    />
    <p @click="fn" 
    :style="{background: bgColor}"
    >{{ obj.dogName }}</p>
  </div>
</template>

<script>
export default {
  name: "LianxiOne",
  components: {},
  props: {
    obj: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      bgColor: "",
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    fn() {
      this.bgColor = `rgb(${this.getRandomColor()}, ${this.getRandomColor()}, ${this.getRandomColor()})`;
    },
    getRandomColor() {
      return Math.floor(Math.random() * 256);
    },
  },
};
</script>

<style scoped>
div {
  text-align: center;
  width: 200px;
  float: left;
  border: 1px solid blue;
}
img {
  width: 100%;
}
</style>
